package mittens.skat;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;

public class Hand {
	public Hand( ){
		cards_ = new ArrayList<Card>();
	}
	
	public String toString() {
		StringBuffer buf = new StringBuffer();
		for( int index=0; index < cards_.size(); index++ ){
			buf.append("("+(index+1)+") "+ cards_.get(index).toString() +"\n");
		}
		return buf.toString();
	}
	
	public void setGame( int game ){
		for( Card card : cards_ ){
			card.setGame(game);
		}
	}
	
	public void setTrump( int trumpSuit ){
		for( Card card : cards_ ){
			card.setTrumpSuit(trumpSuit);
		}
	}
	
	public void add( Card card ){
		cards_.add(card);
	}
	
	public void add( Card[] cards ){
		for( Card card : cards ){
			cards_.add(card);
		}
	}
	
	public void remove( Card card ){
		cards_.remove(card);
	}
	
	public boolean contains( Card card ){
		return cards_.contains(card);
	}
		
	public void sort( ){
		Collections.sort(cards_);
		Collections.reverse(cards_);
	}
	
	public Iterator<Card> iterator() {
		return cards_.iterator();
	}
	
	private ArrayList<Card> cards_;
}
